<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>location地址栏对象</title>
    <style>
        p{
            text-align: center;
        }
        span{
            color: red;
        }
    </style>
</head>
<body>
    <p>
        注册成功！<span id="time">5</span>秒之后自动跳转到首页...
    </p>
</body>
</html>
<script>
   let num =  document.getElementById("time").innerHTML;
    function online(){
        if(num > 0){
            num--;
            document.getElementById("time").innerHTML=num;
        }else{
            location.href="http://www.baidu.com";
        }
    }
    setInterval("online()",1000);
</script>